package com.yiban.demo.Order.Entity;

import org.springframework.cglib.beans.BeanCopier;

public class OrderTransfer {
    private static final BeanCopier transToVO = BeanCopier.create(OrderPO.class,OrderVO.class,false);
    private static final BeanCopier transToPO = BeanCopier.create(OrderVO.class,OrderPO.class,false);

    public static OrderPO transToOrderPo(OrderVO orderVO) {
        OrderPO po = new OrderPO();
        transToPO.copy(orderVO, po, null);
        return po;
    }


    public static OrderVO transToOrderVo(OrderPO orderPO) {
        OrderVO vo = new OrderVO();
        transToVO.copy(orderPO, vo, null);
        vo.setStatus(OrderStatus.getStatus(orderPO.getStatus()).orElseThrow(()->new RuntimeException("不存在该状态码")).getStatusDesc());
        return vo;
    }
}
